// pages/writenote/writenote.js
Page({
  data:{
    title:"",
    content:"",
    time:"" 
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad () {

  },
  addtitle(e){
    this.setData({
      title:e.detail.value 
    })
    },
    addcontent(e){
      this.setData({
        content:e.detail.value 
      })
      },
      addtime(e){
        this.setData({
          time:e.detail.value 
        })
        },

add(){
  wx.cloud.database().collection('domnote')
.add({
 
  data:{
    title:this.data.title,
    content:this.data.content,
    time:this.data.time
  }
})
.then(res => {
  wx.showToast({
    title: '添加成功！',
    icon:'succes',
    duration: 1000,
    mask:true
  })
  console.log("添加成功",res)
})
.catch(res => {
  console.log("添加失败",res)
  wx.showToast({
    title: '添加失败！',
    icon:'loading',
    duration: 1000,
    mask:true
  })
})
}

 
})